home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Doco ƒ / CSMP ƒ / CSMP-V1-080.TXT < prev    next >
Encoding:
Text File  |  1992-06-30  |  42.6 KB  |  1,180 lines

  1. C.S.M.P. Digest             Thu, 14 May 92       Volume 1 : Issue 80
  2.  
  3. Today's Topics:
  4.  
  5.     How to convince Mac+ it has 6-meg of RAM ?????????
  6.     Anybody using MS DDE AppleEvents?
  7.     Summary of Graf3D (long...)
  8.  
  9.  
  10. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  11.  
  12. These digests are available (by using FTP, account anonymous, your email
  13. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  14. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  15. Questions list.  The last several issues of the digest are available from
  16. sumex-aim.stanford.edu as well.
  17.  
  18. These digests are also available via email.  Just send a note saying that you
  19. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  20. automatically receive each new digest as it is created.
  21.  
  22. The digest is a collection of articles from the internet newsgroup comp.sys.
  23. mac.programmer.  It is designed for people who read c.s.m.p. semi-regularly
  24. and want an archive of the discussions.  If you don't know what a newsgroup
  25. is, you probably don't have access to it.  Ask your systems administrator(s)
  26. for details.  (This means you can't post questions to the digest.)
  27.  
  28. The articles in these digests are taken directly from comp.sys.mac.programmer.
  29. They are not edited; all articles included in this digest are in their original
  30. posted form.  The only articles that are -not- included in these digests are
  31. those which didn't receive any replies (except those that give information
  32. rather than ask a question).  All replies to each article are concatenated
  33. onto the original article in the order in which they were received.  Article
  34. threads are not added to the digests until the last article added to the
  35. thread is at least one month old (this is to ensure that the thread is dead
  36. before adding it to the digests).
  37.  
  38. Send administrative mail to mkelly@cs.uoregon.edu.
  39.  
  40. -------------------------------------------------------
  41.  
  42. From: sietze@tardis.et.tudelft.nl (;Sietze Schukking)
  43. Subject: How to convince Mac+ it has 6-meg of RAM ?????????
  44. Date: 10 Apr 92 10:11:10 GMT
  45. Organization: Delft University of Technology, Dept. of Electrical Engineering
  46.  
  47. Hello, again yesterday I posted the following message to comp.sys.mac.system
  48. and got some responces by mail and saw a follow up which pointed out that i
  49. probably did not make myself clear enough and maybe addressed the wrong group,
  50. this was the original posting:
  51.  
  52. In article <1992Apr09.100610.20514@donau.et.tudelft.nl>, sietze@tardis.et.tudelf
  53. t.nl (;Sietze Schukking) writes:
  54. |> Hello, I have a question:
  55. |>
  56. |> What software must be patched and how to tell a Mac+ that
  57. |> it has more than 4meg of RAM.
  58. |> The Ram is placed for example between 6 and 8 megabytes,
  59. |> the hardware is no problem, there is room and i can do that,
  60. |> but to use it the software must be patched by an INIT (EX) or
  61. |> program or something.
  62. |>
  63. |> So can anybody tell me if this has been done before or
  64. |> what one has to do to get this working.
  65. |>
  66. |> Many thanks
  67. |>
  68. |> Sietze Schukking
  69. |>
  70. |> sietze@tardis.et.tudelft.nl
  71. |>
  72. Well I know the SIMM sockets only except 256kb and  1Mb SIMM's, so maximum
  73. is 4Mb regular. But the address space of the MC68000 processor is 16Mbytes,
  74. partly this is occupied by memory and other peripherals. I have experience
  75. with this hardware as i made a memory extention board to extend my 512KE to
  76. 4Mbyte and you can add a memory expansion board to the processor rather
  77. simply. This board would for example insert 2 megB of RAM between address
  78. 6meg and 8meg.
  79.  
  80. So now the problem again what must i do to let the Mac+ use it?
  81.  
  82. Somebody suggested something like patching some kind of free memory structure
  83. to fake the system into believing it got 8megByte of memory with a non
  84. relocatable block between 4meg and 6meg ( where the ROM's and SCSI are located)
  85.  
  86. I think it is possible (in hardware) to extend the memory configuration of a
  87. Mac+ to 7,5 megB.
  88.  
  89. As you can see I am a hardware person and not to deep into software so please
  90. help me out.
  91.  
  92. Thanks again
  93.  
  94. Sietze Schukking
  95.  
  96. sietze@tardis.et.tudelft.nl
  97.  
  98. +++++++++++++++++++++++++++
  99.  
  100. From: stoodt@cis.umassd.edu (Michael Stoodt)
  101. Date: 10 Apr 92 18:43:20 GMT
  102. Organization: University of Massachusetts Dartmouth
  103.  
  104. In <1992Apr10.101110.4234@donau.et.tudelft.nl> sietze@tardis.et.tudelft.nl (;Sietze Schukking) writes:
  105. >.... This board would for example insert 2 megB of RAM between address
  106. >6meg and 8meg.
  107.  
  108. >So now the problem again what must i do to let the Mac+ use it?
  109.  
  110. >Somebody suggested something like patching some kind of free memory structure
  111. >to fake the system into believing it got 8megByte of memory with a non
  112. >relocatable block between 4meg and 6meg ( where the ROM's and SCSI are located)
  113.  
  114. >I think it is possible (in hardware) to extend the memory configuration of a
  115. >Mac+ to 7,5 megB.
  116.  
  117. >As you can see I am a hardware person and not to deep into software so please
  118. >help me out.
  119.  
  120. You're not going to be able to do this without getting deep into the
  121. software, fiddling around with the Memory Manager's data structures
  122. and patching its calls at init time.  And what you'll get as a result
  123. will be fragmented memory; even if you can convince the Memory Manager
  124. that it's ok for it to have this massive immovable block in the middle
  125. of its space, then (assuming you're running Multifinder or System 7)
  126. an application will be able to access either the bottom part (the
  127. under-4MB area) or the top part (your add-on), but not both, because
  128. the heap the Memory Manager creates for it will have to be contiguous.
  129. (And you won't be able to control in which area the application goes,
  130. either, except by launching them in a certain order - application
  131. heaps are allocated top-down - or by making the application request
  132. too much memory to fit in the smaller of the two parts (note that the
  133. system heap is at the bottom of memory, so the bottom part might have
  134. less space available than the top if the system heap is large
  135. enough).)
  136.  
  137. There comes a point where one says, "this is too much trouble; time to
  138. go out and buy an LC or better"; I think you're probably close to it.
  139.  
  140.                   Michael Stoodt
  141.  
  142. +++++++++++++++++++++++++++
  143.  
  144. From: jimc@isc-br.ISC-BR.COM (Jim Cathey)
  145. Date: 13 Apr 92 20:46:14 GMT
  146. Organization: ISC-Bunker Ramo, An Olivetti Company
  147.  
  148. In article <1992Apr10.101110.4234@donau.et.tudelft.nl> sietze@tardis.et.tudelft.nl (;Sietze Schukking) writes:
  149. >This board would for example insert 2 megB of RAM between address
  150. >6meg and 8meg.
  151. >
  152. >So now the problem again what must i do to let the Mac+ use it?
  153. >
  154. >Somebody suggested something like patching some kind of free memory structure
  155. >to fake the system into believing it got 8megByte of memory with a non-
  156. >relocatable block between 4M and 6M (where the ROM's and SCSI are located).
  157.  
  158. I tried something like this once.  Back in the days of old, I put a 1
  159. MB bank of RAM into my 512KE.  This was for a non-volatile RAM-disk
  160. that wouldn't go away when the system crashed (which I used for my
  161. Aztec C development work).  Worked like a charm --- the normal system
  162. didn't notice this extra RAM (which I think hid at the 2M point,
  163. somewhere the auto-sizing startup code didn't find it).  And, it was
  164. damned FAST!  However, there were times when I wanted to have more main
  165. memory and forgo the RAM disk.  So, I wrote an application (for
  166. Unifinder & System 3.2 days) that moved the application heap to this
  167. extra bank of RAM.  The system heap (and the video [of course] and all
  168. INIT-allocated RAM) stayed where it was, so I had a bigger than Mac+
  169. sized heap to run in.  I remember I didn't have to change all that many
  170. low-memory variables to make this work (half a dozen or less).  I
  171. certainly didn't have to patch any traps, nor write any INITs, nor do
  172. any other ugly stuff.  I just moved one memory zone (that was ugly
  173. enough, I'm sure).
  174.  
  175. Everything worked, except (of course) Microsoft applications.  And only
  176. because they refused to follow the rules (anybody remember the 1MB
  177. address-range limit of their early P-code interpreter?)
  178.  
  179. At the time I wanted to make a unified application heap, that put a
  180. large, fictitious non-relocatable block in there so I could continue
  181. to use the space of the former application heap, but I never got that
  182. working.  It wasn't vital, so I skipped it.  I would probably have
  183. had to patch a trap to do this, so InitApplZone (or whatever) would
  184. invent this bogus block.
  185.  
  186. All this stuff died a flaming death with Multifinder, not surprisingly.
  187. What was surprising was how new a system it would work with if I used
  188. Finder.  I'm not sure, but I think I remember even one of the System 6
  189. variants would work with it.  If not, certainly it was System 4 or
  190. System 5 that did still work.  Anyway, in order to run MF I redesigned
  191. my memory interface with a switch, so I could get a plain 1MB Mac+
  192. view of memory and leave the extra 512K in the ozone, or else the
  193. original situation.  This is what my home Mac uses to this day.  It's
  194. been quite a while since I threw the RAMdisk switch.  Anymore nothing
  195. will fit on a 1MB 'disk', nor will much interesting in the way of a
  196. development environment run well in 1/2M of heap.
  197.  
  198. In effect, development today is much slower than it was a few years
  199. ago.  Fortunately I don't really do any at home.
  200.  
  201. +----------------+
  202. ! II      CCCCCC !  Jim Cathey
  203. ! II  SSSSCC     !  ISC-Bunker Ramo
  204. ! II      CC     !  TAF-C8;  Spokane, WA  99220
  205. ! IISSSS  CC     !  UUCP: uunet!isc-br!jimc (jimc@isc-br.isc-br.com)
  206. ! II      CCCCCC !  (509) 927-5757
  207. +----------------+
  208.             "PC's --- the junk bonds of the computer industry"
  209.  
  210. ---------------------------
  211.  
  212. From: ba0k+@andrew.cmu.edu (Brian Patrick Arnold)
  213. Subject: Anybody using MS DDE AppleEvents?
  214. Date: 9 Apr 92 12:00:47 GMT
  215. Organization: Carnegie Mellon, Pittsburgh, PA
  216.  
  217.  
  218. Hello there,
  219.  
  220.     is anybody reading this implementing Microsoft's DDE AppleEvents in
  221. their applications?  If you're from Microsoft and if you have any
  222. concern at all about a reputation for service, you're also encouraged to
  223. give me a reply.
  224.  
  225.     It seems that nobody on the net (netnews comp.sys.mac.programmer,
  226. comp.ms.windows and comp.ms.windows.programmer) is implementing DDE in
  227. their app, save a fellow trying to use the Excel DDE Macros with a
  228. program called CCalc.  Or at least nobody knows how to answer the
  229. questions I've posted more than a week ago to these places.
  230.  
  231.     Naturally, you'd assume I'd try to call Microsoft to get some
  232. answers.  I happened to call several of Microsoft's byzantine phone
  233. numbers:
  234.  
  235. Microsoft Excel Developer Program   (800) 227-6444 dept ET
  236. (no longer in service, must call the following:)
  237. Microsoft Sales                     (800) 227-4679
  238. (busy twice today, twice yesterday.)
  239. Microsoft Product Support Services  (206) 454-2030
  240. (forwarded to Excel Support:)
  241. Microsoft Excel Support             (206) 454-7080
  242.  
  243. The last number answered my call after I spent 2 minutes realizing the
  244. automated hierarchical "hit a button..." service was a complete waste of
  245. my time.  After being on hold for several minutes listening to the
  246. rocking "on hold" jazz station, I was transferred to another person (I
  247. think it was Sales) who put me on hold for several more minutes until
  248. they told me they would call me back after looking into my question
  249. (which was "can anybody answer a couple of questions I have about
  250. Macintosh DDE AppleEvents?")
  251.  
  252. Do I have to buy an Excel Developer Kit to get a decent answer?  I
  253. naturally assume Microsoft doesn't want to help anyone who isn't paying
  254. for their assistance in generating more revenues, so I figure I must buy
  255. this kit before I can get a decent reply to my questions.
  256.  
  257. Well, I'm pissed and I think this is absurd.  I need answers today, not
  258. next month.
  259.  
  260. - - Brian
  261.  
  262. +++++++++++++++++++++++++++
  263.  
  264. From: breidenb@Informatik.TU-Muenchen.DE (Oliver Breidenbach)
  265. Organization: Technische Universitaet Muenchen, Germany
  266. Date: Fri, 10 Apr 1992 10:11:10 GMT
  267.  
  268.  
  269. In article <sdt_9jC00UhWM6614h@andrew.cmu.edu>, Brian Patrick Arnold <ba0k+@andrew.cmu.edu> writes:
  270.  
  271. |> Well, I'm pissed and I think this is absurd.  I need answers today, not
  272. |> next month.
  273.  
  274. This is not absurd, this is Microsoft.
  275. I seem to recall, that DDE is something like Publish and Subscribe in Windows
  276. 3.x perhaps you should refer to the Windows Reference material.
  277.  
  278. I once bought MS Word 4.0 for the Mac. I sent in my registration card
  279. and now I keep getting all those nifty Windows 3.x informations and
  280. everything about the PC products (I even got an invitation for the Windows
  281. 3.0 rollout event) and how I can upgrade to their newest versions, but I
  282. never got any information that there have been several bugfix releases of the
  283. Word 4.0 (Mac) nor have I heard about Word 5 (Mac) and how to upgrade to it.
  284.  
  285. Call this absurd.
  286.  
  287. Cheers,
  288.  
  289. Oliver.
  290.  
  291. ---------------------------
  292.  
  293. From: howard@rigel.cs.pdx.edu (howard l. berkey)
  294. Subject: Summary of Graf3D (long...)
  295. Date: 7 Apr 92 16:49:43 GMT
  296.  
  297.  
  298.  
  299. I should have made this available for the c.s.m.p. digest...
  300. Have fun!
  301.  
  302.  
  303.  
  304.  
  305.  
  306. - -----------------------press n now if not interested------------------------
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314. Here's all the info I have to date...Good Luck!
  315.     -Howard
  316.  
  317.  
  318.  
  319.  
  320. >From lasleyse@wam.umd.edu Sat Feb 29 17:21:00 1992
  321. Received:  from wor-srv.wam.umd.edu by rigel.cs.pdx.edu (4.1/pdx-client-evision: 1.17 
  322.     id AA27848; Sat, 29 Feb 92 17:20:48 PST
  323. Received: from rac2.wam.umd.edu by wor-srv.wam.umd.edu 
  324.     id <AA05078@wor-srv.wam.umd.edu>; Sat, 29 Feb 92 20:20:35 -0500
  325. From: Scott E. Lasley <lasleyse@wam.umd.edu>
  326. Received: by rac2.wam.umd.edu 
  327.     id <AA09693@rac2.wam.umd.edu>; Sat, 29 Feb 92 20:20:35 -0500
  328. Date: Sat, 29 Feb 92 20:20:35 -0500
  329. Message-Id: <9203010120.AA09693@rac2.wam.umd.edu>
  330. To: howard@rigel.cs.pdx.edu
  331. Subject: Re: Graf3D
  332. Newsgroups: comp.sys.mac.programmer
  333. In-Reply-To: <4906@pdxgate.UUCP>
  334. Organization: Space Physics Group, University of Maryland at College Park
  335. Status: OR
  336.  
  337. i think that Graf3D is documented in the MPW manual.  Here is some info
  338. from the net regarding Graf3D:
  339.  
  340.  
  341. Path: wam!haven!uflorida!uakari.primate.wisc.edu!sdd.hp.com!wuarchive!kuhub.cc.ukans.edu!mlab2
  342. From: mlab2@kuhub.cc.ukans.edu
  343. Newsgroups: comp.sys.mac.programmer
  344. Subject: Graf3D and What I Discovered ThereIn - part 1
  345. Message-ID: <27086.27515590@kuhub.cc.ukans.edu>
  346. Date: 26 Nov 90 23:49:04 GMT
  347. Organization: University of Kansas Academic Computing Services
  348. Lines: 116
  349.  
  350. Some UseNetter's thought this might be beneficial to the net, so, here goes the
  351. first installment of "Graf3D and What I Discovered Therein."  Feel free to
  352. correct and dispute anything I say.  I'm not an expert programmer and only
  353. stumbled through Graf3D a year and a half ago.  Also, sorry, I don't know C.
  354.  
  355. "Graf3D and What I Discovered Therein - Part1"
  356. ==============================================
  357. Here are the following functions/procedures and data types that Graf3D defines:
  358.  
  359. Data Types:
  360.   Fixed    (Essentially a LongInt <32-Bit> number where the high 16 bits
  361.             represent the integer portion of the number and the low 16 bits
  362.             represent the fractional portion of the number.  HiWord and LoWord
  363.             can be used to extract said portions.  To convert a LongInt to a
  364.             Fixed type, divide the LongInt by 65536 <2^16>)
  365.  
  366.   Point3D   = RECORD
  367.                x:Fixed;
  368.                y:Fixed;
  369.                z:Fixed;
  370.             END;
  371.            (Note: Unlike the Point type, h and v are called x and y <and z>
  372.             and are of type Fixed instead of Integer.)
  373.  
  374.   Point2D   = RECORD
  375.                x:Fixed;
  376.                y:Fixed;
  377.             END;
  378.            (Note: Why a Point2D and not just Point?  a- It uses the Fixed type
  379.             variable, and b- It is thus easy to convert between a Point3D and
  380.             Point2D for screen display.)
  381.  
  382.   XfMatrix  = ARRAY [0..3, 0..3] of Fixed;
  383.            (This is the transformation matrix that Graf3D uses to rotate and
  384.             translate points.  If your familiar with the concepts and lingo
  385.             used in 3D graphics, you'll know all about the transformation
  386.             matrix.)
  387.  
  388.   Port3DPtr = ^Port3D;
  389.   Port3D    = RECORD
  390.                 GrPort: GrafPtr;
  391.                 viewRect: Rect;
  392.                 xLeft, yTop, xRight, yBottom: Fixed;
  393.                 pen, penPrime, eye: Point3D;
  394.                 hSize, vSize: Fixed;
  395.                 hCenter, vCenter: Fixed;
  396.                 xCotan, yCotan: Fixed;
  397.                 ident: Boolean;
  398.                 xForm: XfMatrix;
  399.               END;
  400.  
  401.            (I'll discuss each of these fields to the Port3D in the next
  402.             installment.)
  403.  
  404.   (Functions and Procedures)
  405.  
  406. PROCEDURE InitGraf3D (GlobalPtr: Ptr);
  407.  
  408. PROCEDURE Open3DPort (port: Port3DPtr);
  409.  
  410. PROCEDURE SetPort3D (port: Port3DPtr);
  411.  
  412. PROCEDURE GetPort3D (VAR port: Port3DPtr);
  413.  
  414. PROCEDURE MoveTo2D (x, y: Fixed);
  415.  
  416. PROCEDURE MoveTo3D (x, y, z: Fixed);
  417.  
  418. PROCEDURE Move2D (dx, dy: Fixed);
  419.  
  420. PROCEDURE Move3D (dx, dy, dz: Fixed);
  421.  
  422. PROCEDURE LineTo2D (x, y: Fixed);
  423.  
  424. PROCEDURE LineTo3D (x, y, z: Fixed);
  425.  
  426. PROCEDURE Line2D (dx, dy: Fixed);
  427.  
  428. PROCEDURE Line3D (dx, dy, dz: Fixed);
  429.  
  430. FUNCTION Clip3D(src1, src2: Point3D; VAR dst1, dst2: Point);
  431.  
  432. PROCEDURE SetPt3D (VAR pt3D: Point3D; x, y, z: Fixed);
  433.  
  434. PROCEDURE SetPt2D (VAR pt2D: Point2D; x, y: Fixed);
  435.  
  436. PROCEDURE ViewPort (r: Rect);
  437.  
  438. PROCEDURE LookAt (left, top, right, bottom: Fixed);
  439.  
  440. PROCEDURE ViewAngle (angle: Fixed);
  441.  
  442. PROCEDURE Identity;
  443.  
  444. PROCEDURE Scale (xFactor, yFactor, zFactor: Fixed);
  445.  
  446. PROCEDURE Translate (dx, dy, dz: Fixed);
  447.  
  448. PROCEDURE Pitch (xAngle: Fixed);
  449.  
  450. PROCEDURE Yaw (yAngle: Fixed);
  451.  
  452. PROCEDURE Roll (zAngle: Fixed);
  453.  
  454. PROCEDURE Skew (zAngle: Fixed);
  455.  
  456. PROCEDURE Transform (src: Point3D; VAR dst: Point3D);
  457.  
  458. Whew!  That's it.  Most of this has come straight from the MPW documentation. 
  459. I'll discuss each of these in following installments.  For now, you might note
  460. that many of these have direct QuickDraw counterparts (SetPt, InitGraf, etc...)
  461. that should make many of the procedures and functions almost self explanatory.
  462.  
  463. Well, all for now!
  464.  
  465. john calhoun
  466.  
  467.  
  468. Path: wam!haven!udel!wuarchive!kuhub.cc.ukans.edu!mlab2
  469. From: mlab2@kuhub.cc.ukans.edu
  470. Newsgroups: comp.sys.mac.programmer
  471. Subject: Grad3D and What I Discovered Therein - part 2
  472. Message-ID: <27110.2752a9ea@kuhub.cc.ukans.edu>
  473. Date: 28 Nov 90 00:01:13 GMT
  474. Organization: University of Kansas Academic Computing Services
  475. Lines: 97
  476.  
  477. Graf3D and What I Discovered Therein - part 2
  478.  
  479. Yeah, part 1 was pretty much header info.  But, some people may not have it. 
  480. Yes, I will present some code for setting up the 3D port and using it.  Wait
  481. until about part 4 or 5 or so.  This is preliminary stuff to avoid a lot of
  482. confusion later.
  483.  
  484. The only variable type I skipped over last time was the Port3D record.  Here it
  485. is described:
  486.  
  487. Fields of the Port3D;
  488. GPort      This is also documented as GrPort in the MPW docs.  In any event
  489.            it is a pointer to the grafPort associated with the 3D port.  Thus
  490.            standard Quickdraw calls to this port will show up with the 3D
  491.            calls.  Want your 3D to appear white on black?  You can just
  492.            InvertRect the portRect field of the G(r)Port field of your Port3D.
  493.  
  494. viewRect   Viewing rectangle within the grafPort.  In the 3D-way of describ-
  495.            ing a 'point of view', this rectangle corresponds to the base of
  496.            the pyramid formed by the user's "eye" and the four corners of the
  497.            screen.
  498.  
  499. xLeft,     World coordinates corresponding to the viewRect.  You shouldn't
  500. yTop,      have to manipulate these variables directly.  The procedures for
  501. xRight,    setting up the camera take care of these.
  502. yBottom
  503.  
  504. pen        Like the Quickdraw pen, but with 3 dimensional coordinates.
  505.  
  506. penPrime   The pen location as transformed by the xForm matrix.  Thus, calls
  507.            to Yaw, Roll, etc will affect this pen's location.  Again, you
  508.            shouldn't have to manipulate this variable.
  509.  
  510. eye        When you call ViewAngle, this variable is established.  It repres-
  511.            ents the 3D point in space where the apex of the viewing pyramid
  512.            is fixed.
  513.  
  514. hSize,     This will store the half-width and half-height of the viewRect in
  515. vSize      screen coordinates.
  516.  
  517. hCenter,   Center of the viewRect in screen coordinates.
  518. vCenter
  519.  
  520. xCotan,    Graf3D sets these up as viewing cotangents (when you call ViewAngle)
  521. yCotan     for calls to Clip3D.
  522.  
  523. Ident      When TRUE, the transforming routines are skipped.  This is set to
  524.            TRUE when you set the xForm matrix to the identity matrix (non-
  525.            rotated).
  526.  
  527. xForm      This is a 4x4 matrix of variables for transforming points.  All
  528.            calls to Yaw(), Roll(), etc are applied to this matrix and then
  529.            Graf3D uses the matrix to transform points in space.  Unless
  530.            reset by Identity, this matrix will continue to represent the net
  531.            result of all transformation calls.
  532.  
  533. Setting up a port:
  534. As with programs using Quickdraw, a call to IntGraf3D(@thePort3D) must be made
  535. during the initialization portion of your program.  Here is how I've
  536. initialized my 3D port:
  537.  
  538. var
  539.   gPort3D                   :Port3D;
  540.   gPort3DPtr                :Port3DPtr;
  541.   origin                    :Point3D;
  542.   viewScreen                :Rect;
  543.  
  544. begin
  545.   InitGraf3D(@thePort3D);
  546.   Open3DPort(@gPort3D);
  547.   SetRect(viewScreen,100, 20, 348, 144);
  548.   ViewPort(viewScreen);
  549.   LookAt(-983040, 655360, 983040, -655360);
  550.   ViewAngle(1604480);
  551.   SetPt3D(origin, 0, 0, 0);
  552.   gPort3D.eye:= origin;
  553.   FillRect(gPort3D.viewRect, black);
  554.   ...
  555. end;
  556.  
  557. This will set up a small 248x124 3D port in the center of a 7-inch Mac screen. 
  558. As well, it sets the eye at the 'origin' in space looking straight ahead
  559. parallel to the "ground".  Finally it fills it black to look like outer space. 
  560. Those lengthy numbers used in LookAt and ViewAngle are fixed type numbers.  The
  561. ViewAngle (1604480) for example, represents an angle of 24 degrees
  562. (1604480/65536).
  563. Perhaps this is a good time to explain the view angles.  The view angle defines
  564. the amount of perspective given to 3D points and lines when drawn to the
  565. screen.  An angle of 0 represents no perspective (or orthographic) projection. 
  566. 10 degrees is similar to the perspective seen through a telephoto lens, 25
  567. degrees is generally accepted as 'normal' perspective of the human eye, and 80
  568. degree would give you a distorted 'fisheye'-like wide angle perspective.
  569.  
  570. Enough of Part 2.  Stay tuned for more.  Note: I can't get MAIL to work right. 
  571. I can READ but can't reply.
  572.  
  573. john calhoun
  574.  
  575.  
  576. Path: wam!haven!ames!rex!wuarchive!kuhub.cc.ukans.edu!mlab2
  577. From: mlab2@kuhub.cc.ukans.edu
  578. Newsgroups: comp.sys.mac.programmer
  579. Subject: Graf3D and What I Discovered Therein - part 3
  580. Message-ID: <27177.2756a557@kuhub.cc.ukans.edu>
  581. Date: 1 Dec 90 00:30:47 GMT
  582. Organization: University of Kansas Academic Computing Services
  583. Lines: 162
  584.  
  585. Graf3D and What I Discovered Therein - part3
  586.  
  587. Well, I must say I'm posting this all a piece at a time.  I don't have any of
  588. this written all out in one place.  So if you want this, here it is, capture
  589. it.  Also, I'll say again that I am not an expert with this at all.  I have
  590. only experimented with it for a couple of months back when I was first learning
  591. to program the Mac (and learning Pascal too).  So, feel free to post
  592. corrections of any of my errors and take my 'tutorial' as a starting point
  593. only.  I just saw all the confusion about Graf3D and thought, "Well, I could
  594. explain a little bit of it."
  595.  
  596. Drawing in 3D-
  597.  
  598. As I may have hinted at before, all drawing is done 'wireframe' with Graf3D. 
  599. You set up a group of 3D points and use Move3D, MoveTo3D, LineTo3D, etc. to
  600. display your drawing.  I'm sure a guru could take the 2D equivalents of these
  601. screen points and create regions and paint them etc.  For my own purposes, this
  602. would clearly have been too slow.
  603.  
  604. So, how did I optimize Graf3D within the bounds allowed by Graf3D?
  605.  
  606. Setting up your 3D points-
  607.  
  608. Consider a simple cube.  Counting up the vertices gives us 8 points.  If we set
  609. up an array [0..7] of Point3D, we can initialize all these points and then
  610. repeatedly connect-the-dots.  Calls to Yaw, Pitch, etc, and moving the 'eye'
  611. around in space will give us different views of this simple cube.
  612.  
  613. The scale you use for the cube is fairly arbitrary.  Lets use a cube with a
  614. side of length 100 for simplicity.  In your initialization routine you caould
  615. call this:
  616.  
  617.   var
  618.     cubeVertices: array [0..7] of Point3D;
  619.  
  620.   begin
  621.     SetPoint3D(cubeVertices[0], 0, 0, 0);
  622.     SetPoint3D(cubevertices[1], 100, 0, 0);
  623.     SetPoint3D(cubeVertices[2], 100, 100, 0);
  624.     SetPoint3D(cubeVertices[3], 0, 100, 0);
  625.     SetPoint3D(cubeVertices[4], 0, 0, 100);
  626.     SetPoint3D(cubeVertices[5], 100, 0, 100);
  627.     SetPoint3D(cubeVertices[6], 100, 100, 100);
  628.     SetPoint3D(cubeVertices[7], 0, 100, 100);
  629.   ...
  630.   end;
  631.  
  632. An alternate (and perhaps quicker) way of doing this would be to have set up an
  633. array of Fixed [0..7, 0..2].  This way, you never create the 3D points, but
  634. assign the x, y, and z coordinates of each verticee.  MoveTo3D and LineTo3D
  635. (etc) expect you to pass the fixed x, y, and z coordinates anyway.  Using
  636. Point3D's is convenient, but you'll still have to "dissect" the corrdinates out
  637. of these points when you call MoveTo3D, etc.
  638.  
  639. A 'convenient' way around this hassle would be to create your own procedures:
  640. As an example:
  641.   Long way:
  642.  
  643.     MoveTo3D(cubeVertices[i].x, cubeVertices[i].y, cubeVertices[i].z);
  644.  
  645.   A nice procedure:
  646.  
  647.     procedure MoveTo3DPt (thePoint: Point3D);
  648.     begin
  649.       MoveTo3D(thePoint.x, thePoint.y, thePoint.z);
  650.     end;
  651.  
  652.     -now simply call-
  653.     MoveTo3DPt(cubeVertices[i]);
  654.  
  655. I think I'll use this second way here.  (You could make a whole library of
  656. routines that translate 3D points, etc.)
  657. So, you've set up your 3D port (from part 2 of this little piece), and you've
  658. initialized the 8 vertices of your cube, - here is a simple loop to use the
  659. mouse to rotate the points from the perspective of the eye.
  660.  
  661. var
  662.   mousePt:Point;     {A STANDARD QuickDraw point that is}
  663.  
  664. {------}
  665.  
  666.     procedure MoveTo3DPt (thePoint: Point3D);
  667.     begin
  668.       MoveTo3D(thePoint.x, thePoint.y, thePoint.z);
  669.     end;
  670.  
  671. {------}
  672.  
  673.     procedure LineTo3DPt (thePoint: Point3D);
  674.     begin
  675.       LineTo3D(thePoint.x, thePoint.y, thePoint.z);
  676.     end;
  677.  
  678. {------}
  679.  
  680. begin
  681.  
  682.   ...
  683.  
  684.   repeat
  685.     GetMouse(mousePt);
  686.     Roll((256 - mousePt.h) * 3276);  {3276 is about 1/10 of a degree, thus
  687.                                       on a 512 Mac screen, +/- 25 degrees
  688.                                       is your roll velocity}
  689.     origin.z:=origin.z+mousePt.v;    {We'll use the vertical position of the
  690.                                       mouse to change the z coordinate of
  691.                                       the origin (see part 2 for origin}
  692.     gPort3D.eye:=origin;             {Now we set the 'eye' of the 3D port
  693.                                       to the new location of the var origin}
  694.     FillRect(gPort3D.ViewRect, black);  {Erase other points drawn}
  695.     MoveTo3DPt(cubeVertices[0]);
  696.     LineTo3DPt(cubeVertices[1]);
  697.     LineTo3DPt(cubeVertices[2]);
  698.     LineTo3DPt(cubeVertices[3]);
  699.     LineTo3DPt(cubeVertices[0]);
  700.       {We have just drawn the bottom of the cube}
  701.     MoveTo3DPt(cubeVertices[4]);
  702.     LineTo3DPt(cubeVertices[5]);
  703.     LineTo3DPt(cubeVertices[6]);
  704.     LineTo3DPt(cubeVertices[7]);
  705.     LineTo3DPt(cubeVertices[4]);
  706.       {We have now drawn the top of the cube, now to connect the top & bot}
  707.     MoveTo3DPt(cubeVertices[0]);
  708.     LineTo3DPt(cubeVertices[4]);
  709.     MoveTo3DPt(cubeVertices[1]);
  710.     LineTo3DPt(cubeVertices[5]);
  711.     MoveTo3DPt(cubeVertices[2]);
  712.     LineTo3DPt(cubeVertices[6]);
  713.     MoveTo3DPt(cubeVertices[3]);
  714.     LineTo3DPt(cubeVertices[7]);
  715.   until button;     {clicking the mouse button exits the program}
  716. end.
  717.  
  718. So, try that one out.  It's bits from a little test program I wrote.  You'll
  719. also have to have part 2 of my posts to do the port setting up stuff.  I'm
  720. hoping to that this is enough to get most everyone started.
  721.  
  722. I could post more, but mostly program specific stuff.  I will say that my
  723. biggest annoyance with Graf3D was that it is difficult (impossible?) to
  724. actually rotate both the cube AND the eye at the same time.  As I recall,
  725. rotation calls to Yaw and the like actually rotate space about the point
  726. (0,0,0).  If you have, for example, two cubes located in differnt places in
  727. space, calls to pitch will rotate BOTH cubes teeter-totter like about the point
  728. (0,0,0) of space.  I could only imagine setting up SEPERATE 3D grafports for
  729. each cube and copybitting the two (via XOr) to a single 2D grafport on the
  730. screen.  Slow.
  731.  
  732. If anyone has any questions, post them to the net (or mail me I suppose).  I
  733. can't reply to mail sent to me, but I could post more on a particular aspect of
  734. Graf3D to the net.
  735.  
  736. One person mailed me about rotating 3D waveforms and displaying them.  That
  737. would probably be fairly easy to do given the code I've posted.  Define the
  738. waveform as a chain of 3D points stretching across the point (0,0,0).  Move the
  739. eye out away from (0,0,0) but look TOWARD the center of space.  Yaws and Rolls
  740. will gimble the waveform about.  Redraw (point to point) the waveform after
  741. each transformation.  You can scale the waveform by simply moving the eye of
  742. the 3D port toward and away from the center of space.
  743.  
  744. Cheerio.  I'll check the net for requests.
  745.  
  746. john calhoun
  747.  
  748.  
  749. Path: wam.umd.edu!ni.umd.edu!haven.umd.edu!ames!ncar!hsdndev!wysocki@husc.harvard.edu
  750. From: wysocki@husc.harvard.edu (Chris Wysocki)
  751. Newsgroups: comp.sys.mac.programmer
  752. Subject: Re: Think C 5.0, Apple libs and Graf3D
  753. Message-ID: <96@hsdndev.UUCP>
  754. Date: 4 Dec 91 03:20:41 GMT
  755. References: <1991Dec4.005525.13637@ux1.cso.uiuc.edu>
  756. Sender: usenet@hsdndev.UUCP
  757. Organization: Harvard University, Cambridge, MA
  758. Lines: 399
  759.  
  760. In article <1991Dec4.005525.13637@ux1.cso.uiuc.edu>, databoy@mrcnext.cso.uiuc.edu
  761. (John Snook) writes:
  762.  
  763. > Ok, I've got the 5.0 vers, new libs. I'm looking in :Mac Libraries: and I find
  764. > "Graf3D". I'm thinking "oh boy oh boy". I look at the header file in headers:
  765. > apple headers:, Graf3D.h, and I'm thinking "oh shit".
  766. > Any Docs, Suggestions or recomendations would be greatly appreciated.
  767.  
  768. Here's some pseudo-documentation for Graf3D, as well as a couple of sample
  769. programs.  I believe that the Graf3D routines are also documented in one of the
  770. MPW manuals.
  771.  
  772. Chris Wysocki
  773. wysocki@husc.harvard.edu
  774.  
  775. - --------
  776. Graf3D: The Three-dimensional Graphics Library
  777.  
  778. Graf3D draws three dimensional graphics in the two-dimensional environment 
  779. provided by Quickdraw.
  780.  
  781. Graf3D presents a "camera-eye view" of the objects drawn.  With Graf3D 
  782. procedures, the programmer sets the camera's location and field-of-view, 
  783. as well as the location and orientation of the object being viewed.  Graf3D 
  784. manages a "viewing pyramid" whose apex is at the camera's eye and whose base is 
  785. Graf3D's "ViewPort".  The Graf3D package will clip objects being viewed to this 
  786. pyramid.
  787.  
  788. The Graf3D package makes extensive use of the "fixed point" data type.  "Fixed" 
  789. is defined as:
  790.    type 
  791.       fixed = longint;
  792. The high order word of a fixed variable is the integer part;  the low order 
  793. word is the fraction part.  Values are represented in units of 1/65536ths.  For 
  794. example, the number 2.5 would be represented by a "2" in the high word and a 
  795. 32768 in the low order word (32768/65536 = .5), which would yield the longint 
  796. value 163840.  Another way to think of it is that the value of a "fixed" 
  797. variable is the value of the longint divided by 65536.  For more detail see 
  798. Inside Macintosh in the "Introduction to Memory Management" chapter.  
  799.  
  800.  
  801. Graf3D Types
  802.  
  803. Point3D
  804. A Point3D is a record containing three "fixed" coordinates.
  805.  
  806.    Point3D = record
  807.             x : fixed;
  808.             y : fixed;
  809.             z : fixed;
  810.          end;
  811.  
  812. Point2D
  813. A Point2D is a record containing two "fixed" coordinates.
  814.  
  815.    Point2D = record
  816.             x : fixed;
  817.             y : fixed;
  818.          end;
  819.  
  820.  
  821. XfMatrix
  822. An XfMatrix is a 4x4 matrix of "fixed" values that holds the transformation 
  823. equation for points to be viewed.
  824.  
  825.       XfMatrix = array [0..3, 0..3] of fixed;
  826.  
  827. Port3D
  828. The Port3D contains all of the state variables necessary to map the three 
  829. dimensional coordinates of the image into the two dimensional screen coordinates.  
  830. "GrPort" is the pointer to the QuickDraw grafPort associated with this Port3D.  
  831. "viewRect" is the viewing rectangle within the Port3D.  "xLeft, yTop, xRight, 
  832. yBottom" are the coordinates of the viewRect in the three-dimensional "world".  
  833. "pen" is the three dimensional pen location.  "penPrime" is the pen location 
  834. transformed by the "xForm" matrix.  "eye" is the position of the camera in 
  835. three-dimensional coordinates.  "hSize, vSize" are the half-width and half-
  836. height of the viewPort in screen coordinates.  "hCenter, vCenter" are the 
  837. coordinates of the center of the viewPort in screen coordinates.  "xCotan, 
  838. yCotan" are the cotangents of the horizontal and vertical viewing angles.  
  839. "ident" is a boolean which is true when "xForm" is equal to the identity 
  840. transformation.  "xForm" is the transformation matrix.
  841.  
  842.    Port3DPtr = ^Port3D;
  843.    Port3D = record
  844.             GrPort : GrafPtr;
  845.             viewRect : Rect;
  846.             xLeft, yTop, xRight, yBottom : fixed;
  847.             pen, penPrime, eye : Point3D;
  848.             hSize, vSize : fixed;
  849.             hCenter, vCenter : fixed;
  850.             xCotan, yCotan : fixed;
  851.             ident : BOOLEAN;
  852.             xForm : XfMatrix;
  853.          end;
  854.  
  855.  
  856.  
  857.  
  858. Graf3D Procedures and Functions
  859.  
  860. Graf3D is a three dimensional Quickdraw package.  Its types, variable and 
  861. routines mimic Quickdraw in many ways.  The following procedures and functions 
  862. are provided in the Graf3D package:
  863.  
  864. Graf3DPort port initialization routines:
  865.  
  866. var thePort3D : Port3DPtr;
  867. procedure InitGrf3D (globalPtr : Ptr);
  868.  
  869. InitGrf3D initializes the Graf3D drawing environment.  This procedure should be 
  870. called once and only once per program execution, after Quickdraw is initialized.  
  871. "globalPtr" is a pointer to the storage you wish to use for the Graf3D global 
  872. variables.  Lightspeed Pascal programmers should always pass "@thePort3D" in 
  873. this parameter.
  874.  
  875. procedure Open3DPort (port : Port3DPtr);
  876. Open3DPort opens and initializes a 3D GrafPort whose space is pointed to by the 
  877. parameter "port".  It also sets "thePort3D" (the current Graf3DPort) to "port".
  878.  
  879. procedure SetPort3D (port : Port3DPtr);
  880. SetPort3D sets the current Graf3DPort ("thePort3D") to "port" and calls SetPort 
  881. for "port"'s associated grafPort.
  882.  
  883. procedure GetPort3D (var port : Port3DPtr);
  884. GetPort3D returns a pointer to the current graf3DPort in "port".  This is useful 
  885. when the programmer wishes to change ports for drawing something and then 
  886. restore the port before proceeding with the rest of the program.  For example:
  887.  
  888. var
  889.    myPort, savePort: Port3DPtr;
  890. ..
  891.    GetPort3D( savePort );     { save the current port }
  892.    SetPort3D( myPort );    { set the port to my own }
  893.    { I can do my drawing nowI }
  894.    SetPort3D( savePort );     { restore the port to the one saved }
  895.  
  896.  
  897. Pen movement and drawing
  898.  
  899. The following routines are used to move the pen in the 3D space and draw lines 
  900. in the space.  NOTE:  The coordinates in these routines are specified in "fixed 
  901. point" notation (NOT INTEGERS as in Quickdraw).
  902.  
  903. procedure MoveTo2D (x, y : fixed);
  904. procedure MoveTo3D (x, y, z : fixed);
  905. These procedures move the pen to the designated coordinates.  (MoveTo2D moves 
  906. without changing the Z-coordinate.)
  907.  
  908. procedure LineTo2D (x, y : fixed);
  909. procedure LineTo3D (x, y, z : fixed);
  910. These procedures draw lines from the current pen position to the given 
  911. coordinates (LineTo2D draws without changing the z-coordinate, i.e. the line is 
  912. drawn in the same z-plane.)
  913.  
  914. procedure Move2D (dx, dy : fixed);
  915. procedure Move3D (dx, dy, dz : fixed);
  916. These procedures move the pen by the specified amounts relative to the current 
  917. pen position.  (Move2D moves without changing the Z-coordinate.)
  918.  
  919. procedure Line2D (dx, dy : fixed);
  920. procedure Line3D (dx, dy, dz : fixed);
  921. These procedures draw lines from the current pen position to the given offsets 
  922. relative to the current pen position (Line2D draws without changing the 
  923. z-coordinate, i.e. the line is drawn in the same z-plane.)
  924.  
  925. function Clip3D (src1, src2 : Point3D;  var dst1, dst2 : POINT): boolean;
  926. Clip3D clips a three-dimensional line segment to the viewing pyramid and returns 
  927. the clipped line projected onto screen coordinates.  Clip3D returns true if any 
  928. part of the line is visible.
  929.  
  930. procedure SetPt3D ( var pt3D : Point3D;  x, y, z : fixed);
  931. SetPt3D assigns the 3 fixed numbers "x,y,z" to the point pt3D.
  932.  
  933. procedure SetPt2D ( var pt2D : Point2D;  x, y : fixed);
  934. SetPt3D assigns the 2 fixed numbers "x,y" to the point pt2D.
  935.  
  936.  
  937. Setting up the point of view
  938.  
  939. The following three procedures set the position and field-of-view of the "point 
  940. of view".
  941.  
  942. procedure LookAt (left, top, right, bottom : fixed);
  943. LookAt specifies the real number x,y coordinates of the viewing rectangle.
  944.  
  945. procedure ViewPort (r : Rect);
  946. ViewPort specifies where to put the image in the grafPort.  The ViewPort 
  947. rectangle is specified in integer coordinates and tells where to map the LookAt 
  948. coordinates.
  949.  
  950. procedure ViewAngle (angle : fixed);
  951. ViewAngle controls the amount of perspective by specifying the horizontal angle 
  952. subtended by the viewing rectangle.  Typical ViewAngles are 0! (no perspective), 
  953. 10! (telephoto lens), 25! (normal human eye), and 80! (wide angle lens).
  954.  
  955.  
  956. Transformation matrix procedures
  957.  
  958. The following procedures modify the transformation matrix that is used to plot 
  959. the points in the viewing coordinates.
  960.  
  961. procedure Identity;
  962. Identity sets the transformation matrix to the identity matrix.
  963.  
  964. procedure Scale (xFactor, yFactor, zFactor : fixed);
  965. Scale modifies the transformation matrix so as to shrink or expand the image by 
  966. the factors specified.
  967.  
  968. procedure Translate (dx, dy, dz : fixed);
  969. Transform modifies the transformation matrix so as to displace the image by the 
  970. specified amounts in the three coordinates.
  971.  
  972. procedure Pitch (xAngle : fixed);
  973. Pitch modifies the transformation matrix so as to rotate "xangle" degrees around 
  974. the x axis.  Positive values cause a clockwise rotation when looking at the 
  975. origin from positive x.
  976.  
  977. procedure Yaw (yAngle : fixed);
  978. Yaw modifies the transformation matrix so as to rotate "yAngle" degrees around 
  979. the y axis.  Positive values cause a clockwise rotation when looking at the 
  980. origin from positive y.
  981.  
  982. procedure Roll (zAngle : fixed);
  983. Roll modifies the transformation matrix so as to rotate "zAngle" degrees around 
  984. the z axis.  Positive values cause a clockwise rotation when looking at the 
  985. origin from positive z.
  986.  
  987. procedure Skew (zAngle : fixed);
  988. Skew modifies the transformation matrix so as to skew the image by "zAngle" 
  989. degrees around the z axis.  Skew only changes the x axis.  Positive values cause 
  990. a clockwise rotation when looking at the origin from positive z.
  991.  
  992. procedure TransForm (src : Point3D;  var dst : Point3D);
  993. Transform applies the transformation matrix to the "src" point, and returns the 
  994. result in "dst".
  995.  
  996.  
  997.  
  998. program boxes;
  999.    uses
  1000.       Graf3D;
  1001.  
  1002.    const
  1003.       boxcount = 10;
  1004.  
  1005.    type
  1006.       box3d = record
  1007.             pt1 : Point3D;
  1008.             pt2 : point3D;
  1009.             dist : real;
  1010.          end;
  1011.  
  1012.    var
  1013.       GPort1 : GrafPort;
  1014.       GPort2 : Port3D;
  1015.       myPort : GrafPtr;
  1016.       myPort3D : Port3DPtr;
  1017.       boxArray : array[0..boxCount] of Box3D;
  1018.       nBoxes : integer;
  1019.       i : integer;
  1020.       ph : picHandle;
  1021.       r : rect;
  1022.  
  1023.    function HeapError (hz : QDPtr;
  1024.             bytesNeeded : integer) : integer;
  1025.    begin
  1026.       writeln('The heap is full!!!');
  1027.    end;
  1028.  
  1029.    function Distance (pt1, pt2 : Point3D) : real;
  1030.       var
  1031.          dx, dy, dz : real;
  1032.    begin
  1033.       dx := pt2.x - pt1.x;
  1034.       dy := pt2.y - pt1.y;
  1035.       dz := pt2.z - pt1.z;
  1036.       Distance := sqrt(dx * dx + dy * dy + dz * dz);
  1037.    end;
  1038.  
  1039.    procedure  MakeBox;
  1040.       label
  1041.          99;
  1042.       var
  1043.          myBox : Box3D;
  1044.          i, j, k, v : integer;
  1045.          p1, p2 : point3D;
  1046.          myRect : Rect;
  1047.          testRect : Rect;
  1048.    begin
  1049.       p1.x := (Random mod 140 - 85) * 65536;
  1050.       p1.y := (Random mod 140 - 80) * 65536;
  1051.       p1.z := 0;
  1052.       p2.x := p1.x + (10 + abs(Random) mod 30) * 65536;
  1053.       p2.y := p1.y + (10 + abs(Random) mod 45) * 65536;
  1054.       p2.z := p1.z + (10 + abs(Random) mod 35) * 65536;
  1055.       SetRect(myRect, round(p1.x div 65536), round(p1.y div 65536), round(p2.x div 65536),            round(p2.y div 65536));
  1056.       for i := 1 to nBoxes - 1 do
  1057.          begin
  1058.             with boxArray[i] do
  1059.                SetRect(testRect, round(pt1.x DIV 65536), round(pt1.y DIV 65536),                      round(pt2.x DIV 65536), round(pt2.y DIV 65536));
  1060.             if sectrect(myRect, testRect, testRect) then
  1061.                goto 99;
  1062.          end;
  1063.       myBox.pt1 := p1;
  1064.       myBox.pt2 := p2;
  1065.       p1.x := (p1.x + p2.x) DIV 2;
  1066.       p1.y := (p1.y + p2.y) DIV 2;
  1067.       p1.z := (p1.z + p2.z) DIV 2;
  1068.       Transform(p1, p2);
  1069.       myBox.dist := Distance(p2, myPort3D^.eye);
  1070.       i := 0;
  1071.       boxArray[nBoxes].dist := myBox.dist;
  1072.       while myBox.dist > boxArray[i].dist do
  1073.          i := i + 1;
  1074.       for j := nBoxes downto i + 1 do
  1075.          boxArray[j] := boxArray[j - 1];
  1076.       boxArray[i] := myBox;
  1077.       nBoxes := nBoxes + 1;
  1078. 99 :
  1079.    end;
  1080.  
  1081.    procedure drawBox (pt1, pt2 : Point3D);
  1082.       var
  1083.          tempRgn : RgnHandle;
  1084.    begin
  1085.       tempRgn := NewRgn;
  1086.       OpenRgn;
  1087.       MoveTo3D(pt1.x, pt1.y, pt1.z);
  1088.       LineTo3D(pt1.x, pt1.y, pt2.z);
  1089.       LineTo3D(pt2.x, pt1.y, pt2.z);
  1090.       LineTo3D(pt2.x, pt1.y, pt1.z);
  1091.       LineTo3D(pt1.x, pt1.y, pt1.z);
  1092.       CloseRgn(tempRgn);
  1093.       FillRgn(tempRgn, white);
  1094.       FrameRgn(tempRgn);
  1095.       OpenRgn;
  1096.       MoveTo3D(pt1.x, pt1.y, pt2.z);
  1097.       LineTo3D(pt1.x, pt2.y, pt2.z);
  1098.       LineTo3D(pt2.x, pt2.y, pt2.z);
  1099.       LineTo3D(pt2.x, pt1.y, pt2.z);
  1100.       LineTo3D(pt1.x, pt1.y, pt2.z);
  1101.       CloseRgn(tempRgn);
  1102.       FillRgn(tempRgn, gray);
  1103.       OpenRgn;
  1104.       MoveTo3D(pt2.x, pt1.y, pt1.z);
  1105.       LineTo3D(pt2.x, pt1.y, pt2.z);
  1106.       LineTo3D(pt2.x, pt2.y, pt2.z);
  1107.       LineTo3D(pt2.x, pt2.y, pt1.z);
  1108.       LineTo3D(pt2.x, pt1.y, pt1.z);
  1109.       CloseRgn(tempRgn);
  1110.       FillRgn(tempRgn, black);
  1111.       PenPat(white);
  1112.       MoveTo3D(pt2.x, pt2.y, pt2.z);
  1113.       LineTo3D(pt2.x, pt2.y, pt1.z);
  1114.       LineTo3D(pt2.x, pt1.y, pt1.z);
  1115.       PenNormal;
  1116.       DisposeRgn(tempRgn);
  1117.    end;
  1118.  
  1119. begin
  1120.    setrect(r, 0, 40, 512, 342);
  1121.    SetDrawingRect(r);
  1122.    InitGrf3D(@thePort3D);
  1123.    showdrawing;
  1124.    GetPort(myPort);
  1125.    ph := OpenPicture(myPort^.portRect);
  1126.    showpen;
  1127.    myPort3D := @GPort2;
  1128.    Open3DPort(myPort3D);
  1129.    ViewPort(myPort^.portRect);
  1130.    LookAt($FF9C0000, $4B0000, $640000, $FFB50000);
  1131.    ViewAngle($200000);
  1132.    Identity;
  1133.    Roll($140000);
  1134.    Pitch($460000);
  1135.    PenPat(white);
  1136.    BackPat(black);
  1137.    EraseRect(myPort^.portRect);
  1138.    for i := -10 to 10 do
  1139.       begin
  1140.          MoveTo3D(i * 10 * 65536, -100 * 65536, 0);
  1141.          LineTo3D(i * 10 * 65536, 100 * 65536, 0);
  1142.       end;
  1143.    for i := -10 to 10 do
  1144.       begin
  1145.          MoveTo3D(-100 * 65536, i * 10 * 65536, 0);
  1146.          LineTo3D(100 * 65536, i * 10 * 65536, 0);
  1147.       end;
  1148.    nBoxes := 0;
  1149.    repeat
  1150.       MakeBox
  1151.    until nBoxes = boxCount;
  1152.    for i := nBoxes - 1 downto 0 do
  1153.       DrawBox(boxArray[i].pt1, boxArray[i].pt2);
  1154.    HidePen;
  1155.    ClosePicture;
  1156.    readln
  1157. end.
  1158. - --------
  1159.  
  1160.  
  1161.  
  1162. I can't think of anything more politically correct than assasination...:)
  1163. Segmentation Fault (core dumped)
  1164.  
  1165. +++++++++++++++++++++++++++
  1166.  
  1167. From: torello@alessia.dei.unipd.it (Tommaso Centro 310125/IF {*})
  1168. Date: 13 Apr 92 10:16:01 GMT
  1169. Organization: D.E.I.
  1170.  
  1171. Is it possible to use Graf3D in color and how?
  1172. Thanks
  1173.  
  1174. Tom
  1175.  
  1176. ---------------------------
  1177.  
  1178. End of C.S.M.P. Digest
  1179. **********************
  1180.